package com.itheima.hmshopping.dubbo.apiImpl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.hmshopping.dubbo.api.UmsAdminServiceApi;
import com.itheima.hmshopping.dubbo.mapper.UmsAdminMapper;
import com.itheima.hmshopping.entity.UmsAdmin;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@DubboService
public class UmsAdminServiceImpl implements UmsAdminServiceApi {
    @Autowired
    private UmsAdminMapper umsAdminMapper;


    /**
     * 更新用户信息
     * @param umsAdmin
     */
    @Override
    public void updateById(UmsAdmin umsAdmin) {
        umsAdminMapper.updateById(umsAdmin);
    }
    /**
     * 根据用户名查询
     * @param usermane
     * @return
     */
    @Override
    public UmsAdmin getUser(String usermane) {
        LambdaQueryWrapper<UmsAdmin> wrapper =new LambdaQueryWrapper<>();
        wrapper.eq(UmsAdmin::getUsername,usermane);
        return umsAdminMapper.selectOne(wrapper);
    }

    /**
     * 根据id查看用户数据
     * @param id
     * @return
     */
    @Override
    public UmsAdmin selectid(Long id) {
        return umsAdminMapper.selectById(id);
    }

    /**
     * 注册用户
     * @param umsAdminParam
     */
    @Override
    public UmsAdmin addAdmin(UmsAdmin umsAdminParam) {
        umsAdminMapper.insert(umsAdminParam);
        return umsAdminParam;

    }
}
